1. Field of the Invention
The present invention relates to the field of data processing. More particularly, the present invention relates to a method and apparatus for resource transfer.
2. Description of the Related Art
With the population of AJAX to modern web applications, script (e.g. JavaScript™ code) is becoming increasingly more important and has been an indispensable part thereof. However, the following problems can occur during its use.
For example, it will take a relatively long time to transfer the whole JavaScript™ code file from the server side to the client side. Further, it is also a time consuming task to initialize the whole JavaScript™ code file into a machine-executable DOM (Document Object Model) tree, especially when the JavaScript™ code file is relatively large.
Specifically, reference is made to FIG. 1, where resource dependency is schematically shown. In response to a request by a client, server S transfers a file of HTML code 11 to the client. The client displays to the user web page 12. The web page 12 may include various functionalities. These functionalities are implemented by calling various resources, the resources having code or code blocks that perform specific tasks.
Generally, resources may be functions, methods, procedures or subroutines. Resources may be written either in a compiled language such as JAVA™ or C++, or they may be written in an interpreted scripting language such as JavaScript™ or VBScript. Here, the invention is directed primarily to code written in these scripting languages, which are supported by most web browsers at present. Code or code blocks for the resources may be embedded in the HTML code or the HTML code may contain tags that refer 13 to an import file of code 14. As indicated in FIG. 1, the import file of code 14 may be a file of JavaScript™ code.
The web page shown in FIG. 1 is a registration page in which a user enters information, such as, name, address, and e-mail address in text fields. The HTML contains code 15a for a text area. Upon processing the code, the client or the web browser displays corresponding text area 15b, according to the specification of the HTML code 15a. As in this example, the text area 15b is an address field and the code 15a calls a function ValidateAddress( ) 16 to validate data entered into the address field by the user. The function ValidateAddress( ) is found in the JavaScript™ import file FORM.JS referenced by the file of HTML code 11. The ValidateAddress( ) function 16 further calls a method, parse( ) 17, found in another JavaScript™ import file, STRING.JS, to validate data entered into the address field by the user.
In other words, the web page 12 only needs the ValidateAddress( ) function 16 in the JavaScript™ import file FORM.JS and the method parse( ) 17 in the JavaScript™ import file STRING.JS. It does not need other functions in the JavaScript™ import file FORM.JS or other methods in the JavaScript™ import file STRING.JS. However, in the present schemes, other functions in the JavaScript™ import file FORM.JS and other methods in the JavaScript™ import file STRING.JS are also transferred to the client, so that the client has to wait for a relatively long time to receive corresponding files from the server.
Additionally, some JavaScript™ functions, although needed by the web page, are seldom used or not used at all by the web page. However, these JavaScript™ functions are all sent to the client irrespective of their usages. As a result, a user has to wait for a relatively long time before he/she can see the web page.
Accordingly, there is a need for a scheme to overcome the problems outlined above.